import datetime
commodity_cart = []
shopping_if_have_commodity = {"honey":50,
                              "meat":20,
                              "beef":30,
                              "clothes":200,
                              "Laundry detergent":30,
                              "book":30,
                              "coffee":20,
                              "pen":8,
                              "pencil":2,
                              "milk":20
                              }
# 抽优惠券
coupons = {0:"honey",
           1:"meat",
           2:"beef",
           3:"clothes",
           4:"Laundry detergent",
           5:"book",
           6:"coffee",
           7:"pen",
           8:"pencil",
           9:"milk"
           }
coupons_values = {
    "honey":0.8,
    "meat":0.8,
    "beef":0.8,
    "clothes":0.8,
    "Laundry detergent":0.8,
    "book":0.8,
    "coffee":0.8,
    "pen":0.8,
    "pencil":0.8,
    "milk":0.8,
}
get_guess_num = int(input("请写下一个你选中的数字:\n"))
print(f"恭喜你抽中了{coupons[get_guess_num]}的{int(coupons_values[coupons[get_guess_num]]*10)}折优惠券")

# 每次购买信息
shopping_info = []
# 自己带了多少钱
money = int(input("想一想，自己带了多少钱\n"))
# 购买数量
commodity_num =0
# 购买总额
sum_num = 0
# 作最后退出的选择按钮
chance = True
# 退货功能
reback = True



while chance:
    get_item = input("想购买什么\n")
    if get_item in shopping_if_have_commodity.keys():
        if shopping_if_have_commodity["{}".format(get_item)] < money:
            commodity_cart.append(get_item)
            if get_item == coupons[get_guess_num]:

                money -= shopping_if_have_commodity[get_item]*(coupons_values[coupons[get_guess_num]])
                sum_num += shopping_if_have_commodity[get_item]*(coupons_values[coupons[get_guess_num]])
            else:
                money -= shopping_if_have_commodity[get_item]
                sum_num += shopping_if_have_commodity[get_item]
            commodity_num += 1
            print("恭喜，购买成功！您的卡余额还剩{}".format(money))
        else:
            print("穷鬼，钱不够！请到其他超市购买！")
    else:
        print("没有这个商品，别瞎弄！")
    reback_chance = input("请问是否想退回哪件物品yes/no\n")
    if reback_chance == "yes":
        reback_commodity = input("请问想退回哪件物品\n")
        del commodity_cart[commodity_cart.index(reback_commodity)]
        if reback_commodity == coupons[get_guess_num]:
            money += shopping_if_have_commodity[get_item]*(coupons_values[coupons[get_guess_num]])
            sum_num -= shopping_if_have_commodity[get_item] * (coupons_values[coupons[get_guess_num]])
            print("您的卡余额目前还剩{}".format(money))

        else:
            money += shopping_if_have_commodity[get_item]
            sum_num -= shopping_if_have_commodity[get_item]
            print("您的卡余额目前还剩{}".format(money))
    chance = input("是否还想继续购买yes/no\n")
    if chance == "yes":
        chance = True
    else:
        chance = False

shopping_info.append(f"购物时间:{datetime.datetime.now()}  卡余额:{money}  购买数量:{commodity_num}  本次购买商品总价值{sum_num}")
print(shopping_info)


